﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BoostSite.Demo.Definitions.Base.Controllers;
using BoostSite.Demo.Definitions.Templates;
using BoostSite.Demo.Definitions.Templates.PageTypes.General;
using BoostSite.Demo.WebMvc.ViewModels;
using EPiBoost.Core.Extensions;
using EPiBoost.Core.Filters.PageFilters;
using EPiBoost.Core.Model;
using EPiServer;
using EPiServer.Filters;

namespace BoostSite.Demo.WebMvc.Areas.General.Controllers
{
	public class StartPageController : BasePageController<StartPage>
    {
		IContentRepository _dataFactory;

		//public StartPageController(IContentRepository dataFactory)
		//{
		//    _dataFactory = dataFactory;
		//}

        //
        // GET: /General/StartPage/
		public ActionResult Index(StartPage currentPage)
		{  
			var model = new StartPageViewModel
			            	{
			            		MainBlocks = currentPage.MainBlocks,
			            		MainIntro = currentPage.MainIntro,
			            		MainTitle = currentPage.MainTitle,
			            	};

			model.Pages = currentPage.GetAllDescendants();

			var paginationFilter = new FilterPagination(3);
			model.Pages.Filter(new FilterCanRender())
					   .Filter(new FilterSort(FilterSortOrder.Alphabetical))
					   .Filter(paginationFilter);

			model.PaginationLinks = paginationFilter.PaginationLinks;
			
            return View(model);
        }

    }
}
